package collection.day04;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * @Author: Miyako
 * @Date: 2024-07-15-10:06
 * @Description:
 */
public class CollectionSortDemo02 {


    public static void main(String[] args) {

        Rect r1 = new Rect(10,5);//向上装箱
        Rect r2 = new Rect(1,50);
        Rect r3  = new Rect(30,1);
        List<Rect> rectList  = new ArrayList<>();
        rectList.add(r1);
        rectList.add(r2);
        rectList.add(r3);
        System.out.println(rectList);
        Collections.sort(rectList);//实际上通过重写compare方法实现排序，将Rect里的宽度组成一个新的集合然后再对其使用sort方法
        System.out.println(rectList);


    }


}
